<template>
  <div class="container" @click="detail(data.id, data.isNeedPassword)">
    <div class="img-show">
      <span class="thumbnail-screen"></span>
      <img class="crane-thumbnail" :src="data.coverPathDesc" alt="" />
    </div>
    <div class="main-article">
      <div class="tag">
        <b>{{ data.tagNames[0] }}</b>
        <em v-for="(item, index) in data.tagNames" :key="index">
          # {{ item }}
        </em>
      </div>
      <div class="title-container">
        <span class="title">{{ data.title }}</span>
        <svg-icon
          v-if="data.isNeedPassword"
          name="lock"
          class="svg-icon"
        ></svg-icon>
      </div>

      <p v-html="data.content"></p>
      <div class="article-footer">
        <img :src="data.creatorAvatar" alt="" />
        <span class="creator-name">{{ data.creatorName }}</span>
        <span class="time">发布于 {{ data.gmtCreate }}</span>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import SvgIcon from '@/components/SvgIcon.vue';
import { ArticleListVO } from '@/pages/index/index.ts';

defineProps<{
  data: ArticleListVO;
  detail: Function;
}>();
</script>

<style scoped lang="less">
.container {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  box-sizing: border-box;
  border-radius: 10px;
  background-color: var(--background-secondary);
  box-shadow: var(--crane-ring-offset-shadow, 0 0 #0000),
    var(--crane-ring-shadow, 0 0 #0000), var(--crane-shadow);
  transition: transform 0.2s ease-in-out;
  z-index: 50;

  &:hover {
    transform: scale(1.02);
  }

  .img-show {
    width: 50%;
    height: 100%;
    border-radius: 10px 0 0 10px;
    position: relative;

    .crane-thumbnail {
      width: 120%;
      height: 100%;
      background-repeat: no-repeat;
      background-size: cover;
      display: block;
      object-fit: cover;

      border-radius: 10px 0 0 10px;
    }

    .thumbnail-screen {
      width: 120%;
      height: 100%;
      opacity: 0.4;
      pointer-events: none;
      position: absolute;
      left: 0;
      z-index: 30;

      max-width: 120%;
      mix-blend-mode: screen;

      border-radius: 10px 0 0 10px;

      background: linear-gradient(
        130deg,
        rgb(36, 198, 220),
        rgb(84, 51, 255) 41.07%,
        rgb(255, 0, 153) 76.05%
      );
    }

    &::after {
      pointer-events: none;
      content: '';
      position: absolute;
      z-index: 35;
      left: 71%;
      top: 0;
      height: 100%;
      width: 50%;
      background: var(--gradient-cover);
    }
  }

  .main-article {
    width: 50%;
    height: 100%;
    padding: 50px 20px;
    grid-row: auto;
    box-sizing: border-box;
    z-index: 40;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    cursor: pointer;

    .tag {
      width: 100%;

      b {
        color: var(--text-accent);
      }

      em {
        margin-left: 10px;
        color: var(--font-color-sign);
      }
    }

    .title-container {
      width: 100%;
      display: flex;
      align-items: center;

      .title {
        font-size: 30px;
        margin-top: 30px;
        margin-bottom: 30px;
        font-weight: 800;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: calc(100% - 60px);
      }

      .svg-icon {
        width: 40px;
        height: 40px;
        margin-left: 10px;
      }
    }

    p {
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 4;
      -webkit-box-orient: vertical;
      word-wrap: break-word;
      word-break: break-all;
      font-size: 18px;
    }

    .article-footer {
      display: flex;
      align-items: center;
      justify-content: flex-start;
      flex: 1 1 0;
      font-size: 14px;
      width: 100%;

      img {
        width: 40px;
        height: 40px;
        border-radius: 40px;
        box-shadow: var(--crane-ring-offset-shadow, 0 0 #0000),
          var(--crane-ring-shadow, 0 0 #0000), var(--crane-shadow);
        border-style: solid;
        border-color: var(--background-primary);
      }

      span {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      .creator-name {
        margin-left: 10px;
        font-weight: 600;
      }

      .time {
        margin-left: 10px;
        color: var(--font-color-sign);
      }
    }
  }
}
</style>
